
import * as contains from './actionTypes'
import {fromJS } from 'immutable'
const defaultState = fromJS ({
    focused:false,
    list:[],
    mouseIn:false,
    page:0,
    totalPage:1
});

export default (state=defaultState,action)=>{


   /*//  用switch 替换 if语句 if(action.type === contains.SREACH_FOCUS){
    //     return state.set('focused',true)
    // }
    // if(action.type === contains.SREACH_BLUR){
    //    return state.set('focused',false)
    // }
    // if(action.type === contains.CHANGE_LIST){
    //     return state.set('list',action.data)
    // }
    // return state*/

    switch (action.type) {
        case contains.SREACH_FOCUS:
            return state.set('focused',true);
        case  contains.SREACH_BLUR:
            return state.set('focused',false);
        case contains.CHANGE_LIST:
            return state.merge({
                'list': action.data,
                'totalPage':action.totalPage
            });

        case contains.MOUSE_ENTER:
            return state.set('mouseIn',true);
        case contains.MOUSE_LEAVE:
            return state.set('mouseIn',false);
        case contains.CHANGE_PAGE:
            return state.set('page',action.page);
        default:
            return state
    }


}